#ifdef RT_USE_OLD_CONN_WRAP

#ifndef RTSESSIONONEFORWARDMANY_H
#define RTSESSIONONEFORWARDMANY_H

#include "RtSessionInterface.h"
#include "RtConnectionInterface.h"
#include "RtMutex.h"
#include <list>

class /*RT_API_EXPORT*/ CRtSessionOneForwardMany 
	: public IRtSessionOneForwardMany
	, public CRtReferenceControlMutilThread
{
public:
	CRtSessionOneForwardMany();
	virtual ~CRtSessionOneForwardMany();

	// interface IRtReferenceControl
	virtual DWORD AddReference();
	virtual DWORD ReleaseReference();

	// interface IRtSessionOneForwardMany
	virtual RtResult AddTransport(IRtTransport *aTrpt);

	virtual RtResult RemoveTransport(IRtTransport *aTrpt);

	virtual RtResult RemoveAllTransports();
	
	virtual RtResult SendDataToAll(
		CRtMessageBlock &aData, 
		CRtTransportParameter *aPara = NULL,
		IRtTransport *aSender = NULL);

private:
	RtResult Send_i(
		CRtMessageBlock &aData, 
		CRtTransportParameter *aPara, 
		IRtTransport *aSender);

private:
	typedef CRtMutexThread MutexType;
	typedef std::list<CRtAutoPtr<IRtTransport> > TrptsType;

	CRtThread *m_pThreadNetwork;
	MutexType m_Mutex;
	TrptsType m_Trpts;

	friend class CEventSendDataToAll;
};

	class CEventSendDataToAll : public IRtEvent
	{
	public:
		CEventSendDataToAll(
			CRtSessionOneForwardMany *aSession,
			CRtMessageBlock &aData, 
			CRtTransportParameter *aPara,
			IRtTransport *aSender);

		virtual ~CEventSendDataToAll();

		virtual RtResult OnEventFire();

	private:
		CRtAutoPtr<CRtSessionOneForwardMany> m_pOwnerSession;
		CRtMessageBlock *m_pMessageBlock;
		CRtTransportParameter m_TransportParameter;
		CRtTransportParameter *m_pParaTransportParameter;
		CRtAutoPtr<IRtTransport> m_pTransportender;
	};

#endif // !RTSESSIONONEFORWARDMANY_H

#endif // RT_USE_OLD_CONN_WRAP
